<script setup>
import { ArrowLeftIcon } from 'tdesign-icons-vue-next'
import { ref } from 'vue'
import { useRoute, useRouter } from 'vue-router'
import { getAlarmItem } from '@/api/alarm'
import MainContent from '@/components/Main-Content.vue'

const router = useRouter()
const route = useRoute()
const handleStatusMap = {
    0: '未派单',
    1: '已派单',
    2: '已接单',
    3: '已完成',
}
const infoData = ref({})

const back = () => router.back()
const getList = async () => {
    const res = await getAlarmItem(route.query.id)
    infoData.value = res.data
}

getList()
</script>

<template>
    <main-content>
        <div class="header">
            <t-button variant="outline" @click="back">
                <template #icon>
                    <ArrowLeftIcon/>
                </template>
                返回
            </t-button>
            <span class="title">月卡详情记录</span>
        </div>

        <t-divider theme="vertical"/>

        <div class="body">
            <t-card title="告警详情" header-bordered>
                <div class="info">
                    <div class="item">
                        <span>告警时间：</span>
                        <span>{{ infoData.warningTime }}</span>
                    </div>
                    <div class="item">
                        <span>一体杆名称：</span>
                        <span>{{ infoData.poleName }}</span>
                    </div>
                    <div class="item">
                        <span>告警区域：</span>
                        <span>{{ infoData.areaName }}</span>
                    </div>
                    <div class="item">
                        <span>一体杆编号：</span>
                        <span>{{ infoData.poleNumber }}</span>
                    </div>
                    <div class="item">
                        <span>故障类型：</span>
                        <span>{{ infoData.errorType }}</span>
                    </div>
                    <div class="item">
                        <span>处置状态：</span>
                        <span>{{ handleStatusMap[infoData.handleStatus] }}</span>
                    </div>
                </div>
            </t-card>

            <t-card title="告警处理" header-bordered>
                <div class="info">
                    <div class="item">
                        <span>处理人员：</span>
                        <span>{{ infoData.handleUser }}</span>
                    </div>
                    <div class="item">
                        <span>处理结果：</span>
                        <span>{{ infoData.handleResult }}</span>
                    </div>
                    <div class="item">
                        <span>联系方式：</span>
                        <span>{{ infoData.phonenumber }}</span>
                    </div>
                    <div class="item">
                        <span>完成时间：</span>
                        <span>{{ infoData.handleTime }}</span>
                    </div>
                </div>
            </t-card>
        </div>
    </main-content>
</template>

<style scoped lang="scss">
.header {
    display: flex;
    align-items: center;
    padding: 20px 20px 0;

    .title {
        color: var(--td-text-color-primary);
        font-size: 24px;
        font-weight: 600;
        margin-left: 30px;
    }
}

.body {
    padding: 10px 30px;

    .t-card {
        width: 100%;

        .info {
            display: flex;
            flex-wrap: wrap;

            .item {
                width: 50%;
                min-width: 200px;
                min-height: 40px;
                display: flex;
                align-items: center;

                span:first-child {
                    color: var(--td-text-color-secondary);
                }

                span:last-child {
                    font-weight: 500;
                }
            }
        }

        &:first-of-type {
            margin-bottom: 20px;
        }
    }
}

.t-divider {
    margin: 20px 0;
}
</style>
